/**
 * 
 */
package info.niwota.fwrite.svg;

import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

import android.gesture.Gesture;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;

/**
 * @author qiangli
 * 
 */
public class GraphicsGenerator {
	public static final String SVG_OPEN = "<?xml version=\"1.0\" standalone=\"no\"?>"
			+ "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">"
			+ "<svg width=\"100%\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">";
	public static final String SVG_CLOSE = "</svg>";

	/**
	 * 
	 */
	public GraphicsGenerator() {
	}

	public void append(Gesture g) {
		/*
		 * M = moveto L = lineto H = horizontal lineto V = vertical lineto C =
		 * curveto S = smooth curveto Q = quadratic Belzier curve T = smooth
		 * quadratic Belzier curveto A = elliptical Arc Z = closepath
		 */
		Path p = g.toPath();
		Canvas c = new Canvas();
		c.drawPath(p, new Paint());
	}

	public Document parse(InputStream in) {
		Document doc = null;
		try {
			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
			DocumentBuilder db = dbf.newDocumentBuilder();
			doc = db.parse(in);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return doc;
	}
}
